package pers.xuankai.springboot.utils;

public class JsonResult<T> {
    private T data;
    Meta meta;

    public JsonResult(){
        meta = new Meta(200, "操作成功。");
    }

    public JsonResult(int status, String message){
        meta = new Meta(status, message);
    }

    public JsonResult(T data, int status, String message){
        this.data = data;
        meta = new Meta(status, message);
    }

    public JsonResult(T data){
        this.data = data;
        meta = new Meta(200, "操作成功。");
    }

    public T getData() {
        return data;
    }

    public Meta getMeta() {
        return meta;
    }

    private static class Meta{
        private final int status;
        private final String message;

        public Meta(int status, String message){
            this.status = status;
            this.message = message;
        }

        public int getStatus() {
            return status;
        }

        public String getMessage() {
            return message;
        }
    }
}
